<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <link rel="stylesheet" href="/plugins/layui/css/public.css" media="all" />
    <script type="text/javascript" src="/plugins/layui/layui.js"></script>
    <script type="text/javascript" src="/js/global-config.js"></script>
    <title>新增编辑概括</title>
</head>
<body>
<div style="margin: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>
            编辑概括(<label class="layui-required-tip">标红的为必填项</label>)
        </legend>
    </fieldset>
    <form class="layui-form" id="layui-form" action="/manage/summarize/addSummarize" method="post">
        <input type="hidden" name="currencyInfoId" autocomplete="off" class="layui-input" value="${currencyInfoId!}">
        <div class="layui-form-item">
            <label class="layui-form-label"><b>基本信息：</b></label>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题：</label>
            <div class="layui-input-block">
                <input type="text" name="title"  id="title"
                       maxlength="64" placeholder="请输入标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">项目简介：</label>
            <div class="layui-input-block">
                <textarea id="intruduction" name="intruduction" maxlength="1024"
                          placeholder="请输入项目简介" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发行时间：</label>
            <div class="layui-input-block">
                <input id="releaseTime" class="layui-input" name="releaseTime" placeholder="请输入发行时间">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label layui-required-tip">发行价格：</label>
            <div class="layui-input-block">
                <input type="text" name="releasePrice"  id="releasePrice" maxlength="12"
                       lay-verify="number" placeholder="请输入发行价格" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发行总量：</label>
            <div class="layui-input-block">
                <input type="text" name="releaseTotal"  id="releaseTotal" maxlength="20"
                       lay-verify="number" placeholder="请输入发行总量" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><b>公募信息：</b></label>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公募时间：</label>
            <div class="layui-input-block">
                <input id="publicOfferTime" class="layui-input" name="publicOfferTime" placeholder="请输入公募时间">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">ICO成本：</label>
            <div class="layui-input-block">
                <input type="text" name="icoCost"  id="icoCost" maxlength="12"
                       placeholder="请输入ICO成本" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">募集资金：</label>
            <div class="layui-input-block">
                <input type="text" name="raiseFunds"  id="raiseFunds" maxlength="12"
                       placeholder="请输入募集资金" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item tokenDistribution" style="display: none;">
            <label class="layui-form-label">代币分配：</label>
            <div class="layui-input-block">
                <input type="text" name="tokenDistribution" id="tokenDistribution" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline tokenDistribution">
            <label class="layui-form-label layui-required-tip">代币分配：</label>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="ico" onkeyup="eventtokenMsg();" class="layui-input ico1">
            </div>
            <div class="layui-input-inline">
                <input type="text" autocomplete="off" placeholder="foundation" onkeyup="eventtokenMsg();" class="layui-input foundation1">
            </div>
            <div class="layui-input-inline">
                <a class="layui-btn layui-btn-normal" id="addtoken"><i class="layui-icon">&#xe654;</i></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">官网链接：</label>
            <div class="layui-input-block">
                <input type="text" name="websiteLink"  id="websiteLink" maxlength="64"
                       placeholder="请输入官网链接" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">白皮书：</label>
            <div class="layui-input-block">
                <input type="text" name="whitePaper"  id="whitePaper" maxlength="64"
                       placeholder="请输入白皮书" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">支持钱包：</label>
            <div class="layui-input-block">
                <input type="text" name="supportPurse"  id="supportPurse" maxlength="128"
                       placeholder="请输入支持钱包" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><b>团队介绍：</b></label>
            <div class="layui-input-block" style="display: none;">
                <input type="text" id="personExt" name="personExt" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline person" id="person">
            <label class="layui-form-label layui-required-tip">人物信息：</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="姓名" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input name1">
            </div>
            <div class="layui-input-inline">
                <input type="text" placeholder="职位" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input job1">
            </div>
            <div class="layui-input-inline">
                <input type="text" placeholder="相关链接(填写格式：link1,link2...)" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input link1">
            </div>
            <div class="layui-input-inline">
                <a class="layui-btn layui-btn-normal" id="addperson"><i class="layui-icon">&#xe654;</i></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><b>路线图：</b></label>
            <div class="layui-input-block" style="display: none;">
                <input type="text" id="courseExt" name="courseExt" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-inline course" id="course">
            <label class="layui-form-label layui-required-tip">路线信息：</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="时间" autocomplete="off" lay-verify="required" onkeyup="eventCourseMsg();" class="layui-input time1">
            </div>
            <div class="layui-input-inline">
                <input type="text"  placeholder="大事件" autocomplete="off" lay-verify="required" onkeyup="eventCourseMsg();" class="layui-input event1">
            </div>
            <div class="layui-input-inline">
                <a class="layui-btn layui-btn-normal" id="addline"><i class="layui-icon">&#xe654;</i></a>
            </div>
        </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
            <button class="layui-btn" lay-filter="reset" type="reset">重置</button>
            <button type="button" class="layui-btn layui-btn-primary" onclick="javascript:history.back();" >返回</button>
        </div>
    </div>
</form>
</div>
<script>
    layui.use(["jquery","form","laydate"],function () {
        var $ = layui.jquery,form = layui.form,laydate =layui.laydate,i=2,j=2,m = 2,x,y,z;

        //人物信息
        $("#addperson").on("click",function () {
            if(i >= 16){
                layer.msg("最多添加15组",{icon:7, shift: 6 });
                return;
            }
            $("form .person:last").after(
                '<div class="layui-form-item layui-inline person">'+
                '<label class="layui-form-label" style="color: white;">人物信息：</label>'+
                '<div class="layui-input-inline">'+
                '<input type="text" placeholder="姓名" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input name'+i+'"/>'+
                '</div><div class="layui-input-inline">'+
                '<input type="text" placeholder="职位" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input job'+i+'">'+
                '</div><div class="layui-input-inline">'+
                '<input type="text" placeholder="相关链接(填写格式：link1,link2...)" lay-verify="required" onkeyup="eventPersonMsg();" autocomplete="off" class="layui-input link'+i+'">'+
                '</div><div class="layui-input-inline">'+
                '<a class="layui-btn layui-btn-normal" onclick="delePersonMsg(this)"><i class="layui-icon" style="font-size: 17px">&#x1006;</i></a>'+
                '</div></div>'
            );
            i++;
        });

        //路线信息
        $("#addline").on("click",function () {
            if(j >= 16){
                layer.msg("最多添加15组",{icon:7, shift: 6 });
                return;
            }
            $("form .course:last").after(
                '<div class="layui-form-item layui-inline course">'+
                '<label class="layui-form-label" style="color: white;">路线信息：</label>'+
                '<div class="layui-input-inline">'+
                '<input type="text" placeholder="时间" lay-verify="required" autocomplete="off" onkeyup="eventCourseMsg();" class="layui-input time'+j+'">'+
                '</div><div class="layui-input-inline">'+
                '<input type="text" placeholder="大事件" lay-verify="required" autocomplete="off" onkeyup="eventCourseMsg();" class="layui-input event'+j+'">'+
                '</div><div class="layui-input-inline">'+
                '<a class="layui-btn layui-btn-normal" onclick="delecourseMsg(this)"><i class="layui-icon" style="font-size: 17px">&#x1006;</i></a>'+
                '</div></div>'
            );
            j++;
        });

        //代币分配
        $("#addtoken").on("click",function () {
            if(m >= 16){
                layer.msg("最多添加15组",{icon:7, shift: 6 });
                return;
            }
            $("form .tokenDistribution:last").after(
                '<div class="layui-form-item layui-inline tokenDistribution">'+
                '<label class="layui-form-label" style="color: white;">代币分配：</label>'+
                '<div class="layui-input-inline">'+
                '<input type="text" placeholder="ico" lay-verify="required" autocomplete="off" onkeyup="eventtokenMsg();" class="layui-input ico'+m+'">'+
                '</div><div class="layui-input-inline">'+
                '<input type="text" placeholder="foundation" lay-verify="required" autocomplete="off" onkeyup="eventtokenMsg();" class="layui-input foundation'+m+'">'+
                '</div><div class="layui-input-inline">'+
                '<a class="layui-btn layui-btn-normal" onclick="deltokenMsg(this)"><i class="layui-icon" style="font-size: 17px">&#x1006;</i></a>'+
                '</div></div>'
            );
            m++;
        });

        //人物信息值合并
        function personMsg(){
            var arr = [];
            for(x=1;x <= i-1;x++){
                var link = [];
                if($(".person .link"+x+"").val()){
                    var ar = $(".person .link"+x+"").val().split(',');
                    for(var e =0;e < ar.length;e++){
                        if(ar[e]){
                            link.push({
                                name:'',
                                link:ar[e]
                            })
                        }
                    }
                }
                arr.push({
                    name:$(".person .name"+x+"").val(),
                    link:link,
                    job:$(".person .job"+x+"").val()
                })
            }
            return JSON.stringify(arr);
        }

        //路线信息值合并
        function courseMsg(){
            var arr = [];
            for(y=1;y<=j-1;y++){
                arr.push({
                    time:$(".course .time"+y+"").val(),
                    sort:'',
                    event:$(".course .event"+y+"").val()
                })
            }
            return JSON.stringify(arr);
        }

        //代币分配信息合并
        function tokenMsg() {
            var arr =[];
            for(z =1;z <= m-1;z++){
                arr.push(
                    {
                        ico:$(".tokenDistribution .ico"+z+"").val(),
                        foundation:$(".tokenDistribution .foundation"+z+"").val()
                    })
            }
            return JSON.stringify(arr);
        }

        window.eventPersonMsg=function(){
            $("#personExt").val(personMsg());
        }
        window.eventCourseMsg=function(){
            $("#courseExt").val(courseMsg());
        }
        window.eventtokenMsg = function () {
            $("#tokenDistribution").val(tokenMsg());
        }

        //发行时间选择器
        laydate.render({
            elem: '#releaseTime',
            format: 'yyyy-MM-dd'
        });

        //删除input组
        window.delePersonMsg = function(that) {
            that.parentNode.parentNode.remove();
            i--;
            eventPersonMsg();
        }
        window.delecourseMsg =function(that) {
            that.parentNode.parentNode.remove();
            j--;
            eventCourseMsg();
        }
        window.deltokenMsg =function(that) {
            that.parentNode.parentNode.remove();
            m--;
            eventtokenMsg();
        }

        //监听提交
        form.on('submit(save)', function(data){
            var $layer = $('#layui-form');
            layer.confirm('确认要提交吗？', {
                btn : [ '确定', '取消' ]//按钮
            }, function(index) {
                $layer.submit();
                layer.close(index);
            });
            return false;
        });
    });
</script>
</body>
</html>